package cc.wanforme.st.server.config.db.dynamic;

import java.util.Objects;

public enum TableDbEnum {
	DEFAULT("defaultDb", "default mysql"),
	SQLITE("sqlite", " simple sqllite")
	;
	
	// code 要和配置中实例化的名字对应上
	private String code;
	private String description;
	
	private TableDbEnum(String code, String description) {
		this.code = code;
		this.description = description;
	}
	
	public String getCode() {
		return code;
	}
	public String getDescription() {
		return description;
	}
	
	public static TableDbEnum fromCode(String code) {
		TableDbEnum[] values = TableDbEnum.values();
		if(values!=null) {
			for (TableDbEnum tableDbEnum : values) {
				if(Objects.equals(tableDbEnum.getCode(), code)) {
					return tableDbEnum;
				}
			}
		}
		return null;
	}
}
